#! /usr/bin/env perl
# author: maxiao
# date: 2023-03-07 20:27
# description: 测试持久化私有变量的使用

#use strict;
use utf8;
use v5.10;

# 定义子程序
sub running_sum {
    state $num = 0;
    state @numbers;
    foreach my $number ( @_ ) {
        # 将标量变量$number压入数组@numbers
        push @numbers, $number;
        $num += $number;
    }
    print("\@numbers --->@numbers;\t\$num --->$num\n");
}

running_sum(5, 6);
running_sum(1..3);
running_sum(7);
